package com.iye.puretennis.custom;

import android.app.Activity;
import android.app.Application;

import java.util.LinkedList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: jing wu
 * Date: 2014/12/30
 * Time: 16:43
 */
public class ExitApplication extends Application {

    private List<Activity> activityList = new LinkedList<Activity>();

    private static ExitApplication instance;

    private ExitApplication() {
    }

    //单例模式中获取唯一的ExitApplication 实例
    public static ExitApplication getInstance() {
        if (null == instance) {
            instance = new ExitApplication();
        }
        return instance;
    }


    public void addActivity(Activity activity) {
        activityList.add(activity);
    }

    public void exit() {

        for (Activity activity : activityList) {
            activity.finish();
        }
        System.exit(0);
    }

}
